package Animal;

public class AnimalTest {
    public static void main(String[] args) {
        Animall a = new Animall();
        a.name = "呵呵";
        //a.legs = 2;
        a.age = 1;
        a.show();

    }
}

class Animall {
    String name;
    int age;
    private int legs;//为了防止用户直接调用该属性来赋值

    public void setLegs(int l) {//体现为对属性的设置
        if (l >= 0 && l % 2 == 0) {
            legs = l;
        }
        else {
            legs = 0;
        }
    }

    public int getLegs() {
        return legs;
    }//体现为对于属性的获取

    public void eat() {
        System.out.println("动物进食");
    }

    public void show() {
        System.out.println("name:" + name + "   age:" + age + " legs:" + legs);
    }


}